package nk.presum;

import java.util.Scanner;

public class AB42 {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        String str = scanner.next();
        if (n <= 2)
            System.out.println(0);

        int[] cnt = new int[26];
        long ans = 0;
        for (int i = str.length() - 1; i >= 0 ; i--) {
            int x = str.charAt(i) - 'a';
            for (int j = 0; j < cnt.length; j++) {
                if (j != x && cnt[j] >= 2) {
                    ans += cnt[j] * (cnt[j] - 1) / 2;
                }
            }
            cnt[x]++;
        }
        System.out.println(ans);
    }

}
